package com.janlei.acc.strategy;

import java.lang.reflect.InvocationTargetException;

public interface Operation {

    Double operate(int a, int b);
}

class Math {
    public static Double getResult(Class<? extends Operation> clazz, int a, int b) throws IllegalAccessException,
            InstantiationException, NoSuchMethodException, InvocationTargetException {

        return clazz.getDeclaredConstructor().newInstance().operate(a, b);
    }
}

class AddOperation implements Operation {

    @Override
    public Double operate(int a, int b) {
        return (double) (a + b);
    }
}

class ReduceOperation implements Operation {
    @Override
    public Double operate(int a, int b) {
        return (double) (a - b);
    }
}

/**
 * 乘积
 */
class ProductOperation implements Operation {
    @Override
    public Double operate(int a, int b) {
        return (double) (a * b);
    }
}
